package com.bayair.doctor.ui.login;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.webkit.WebView;
import com.bayair.doctor.App;
import com.bayair.doctor.R;
import com.bayair.doctor.base.component.BaseActivity;
import com.hjq.bar.TitleBar;
import butterknife.BindView;

/**
  协议页面
 */
public class ProtocolActivity extends BaseActivity {

    public static void actionStart(Activity activity,String title) {
        Intent intent = new Intent(activity, ProtocolActivity.class);
        intent.putExtra(PROTOCOL_TITLE, title);
        activity.startActivity(intent);
    }

    private static final String PROTOCOL_TITLE = "protocol_title";

    @BindView(R.id.title_bar)
    TitleBar mTitleBar;
    @BindView(R.id.web_protocol)
    WebView mWebView;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_protocol;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        String title = getIntent().getStringExtra(PROTOCOL_TITLE);
        if (!TextUtils.isEmpty(title)) {
            mTitleBar.setTitle(title);

            String url="file:///android_asset/protocol/user.html";   //这个地址是关键的
            if (TextUtils.equals("用户协议", title)) {
                url = "file:///android_asset/protocol/user.html";
            }

            if (TextUtils.equals("隐私政策", title)) {
                url = "file:///android_asset/protocol/privacy.html";
            }

            mWebView.loadUrl(url);
        }
    }

    @Override
    public void onLeftClick(View v) {
        super.onLeftClick(v);
    }

    @Override
    protected void initData() {

    }

}
